import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class palancaPiso here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class palancaPiso extends palanca
{
    /**
     * Act - do whatever the palancaPiso wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    Mundo w;
    liso piso;
   public  int reg;
   /**
    * constructor de palancaPiso
    * @param recibe el numero de piso
    */
   public palancaPiso(int dato){
       reg=dato;
       piso= new liso(dato);
   }
    
    public void act() 
    {
        // Add your action code here.

        insertaPiso();
    }
    /**
     * Crea el tipo de piso dependiendo el tipo de palanca y lo creara en diferente posicion
     */
  public void  insertaPiso()
  {
     Actor rojo= getOneIntersectingObject(sonicRojo.class);
     Actor azul= getOneIntersectingObject(sonicAzul.class);
     
     w=(Mundo) super.getWorld();
     if(rojo!=null || azul!=null)
     {
         if(reg==2)
          w.addObject(piso,415,80);
          else
         if(reg==7||reg==8)
         w.addObject(piso,150,280);
     }
     else
        w.removeObject(piso);
   } 
}
